package com.sgb.goods.viewmodel;

import androidx.lifecycle.MutableLiveData;

import com.sgb.goods.api.GoodsCallBack;
import com.sgb.goods.api.GoodsNet;
import com.sgb.goods.entity.BrandManagerEntity;
import com.sgb.goods.entity.ProListEntity;
import com.sgb.goods.entity.order.LogisticsAgreementEntity;
import com.sgb.goods.utils.Constants;
import com.sgb.goods.utils.base.viewmodel.BaseViewModel;
import com.sgb.goods.view.adapter.order.LogisticsAgreementAdapter;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.util.SharedPreferenceUtil;

import java.util.List;

/**
 * 描述：商品订单中的物流约定
 *
 * @author qiangHeNoo
 * <p>
 * 时间：2021.12.16
 */
public class LogisticsAgreementModel extends BaseViewModel {

    public LogisticsAgreementAdapter adapter;
    public MutableLiveData<List<LogisticsAgreementEntity>> logisticsAgreementEntities = new MutableLiveData<>();

    public LogisticsAgreementModel() {
        adapter = new LogisticsAgreementAdapter();
    }

    /** 查询物流约定列表 */
    public void getLogisticsAgreement(String orderId) {
        showLoading();
        GoodsNet.getInstance().getGoodsApi().getLogisticsAgreement(orderId).enqueue(new GoodsCallBack<BaseEntity<List<LogisticsAgreementEntity>>>() {

            @Override
            public void onSuccess(BaseEntity<List<LogisticsAgreementEntity>> data) {
                logisticsAgreementEntities.setValue(data.getData());
                adapter.setNewData(data.getData());
            }

            @Override
            public void onFail() {
                logisticsAgreementEntities.setValue(null);
            }
        });
    }
}
